!<template>
  <Header>
    <div slot="left" class="header-left" @click.stop="back"></div>
    <p slot="center" class="header-title" :class="{'active':headerTitle}">{{titleText}}</p>
    <div slot="right" class="header-right"></div>
  </Header>
</template>

<script>
import Header from '../Header.vue'
export default {
  name: 'SubHeader',
  components: {
    Header
  },
  data () {
    return {
      headerTitle: true,
      titleText: '歌单®'
    }
  },
  methods: {
    back () {
      window.history.back()
    }
  },
  props: {
    title: {
      type: String,
      default: '',
      required: true
    }
  },
  mounted () {
    this.$bus.$on('titleCheckout', (value) => {
      this.headerTitle = value
    })
  },
  watch: {
    headerTitle (newValue, oldValue) {
      this.titleText = newValue ? '歌单®' : this.title
    }
  }
}
</script>

<style scoped lang='scss'>
@import "../../assets/css/variable";
@import "../../assets/css/mixin";
.header {
  z-index: 99;
  .header-left {
    @include bg_img("../../assets/images/back");
  }
  .header-right {
    @include bg_img("../../assets/images/more");
  }
  .header-title {
    text-align: center;
    line-height: 100px;
    color: white;
    font-size: 36px;
    @include no-wrap();
    &.active{
      position: absolute;
      left: 90px;
    }
  }
}
</style>
